//=============================================================================

#include <windows.h>
#include <gl/gl.h>
#include <time.h>
#include "../../../../inc/aLabyrinth.h"

//=============================================================================

aLabyrinth::aLabyrinth()
{
  sizes[0] = 128;
  sizes[1] = 20;
  sizes[2] = 512;
  sizes[3] = 1024;

  crsMax[0] = 10;
  crsMax[1] = 20;
  crsMax[2] = 40;
  crsMax[3] = 80;

  minRadius[0] = 10.0f;
  minRadius[1] = 20.0f;
  minRadius[2] = 35.0f;
  minRadius[3] = 50.0f;
}

//=============================================================================

void aLabyrinth::alGenerateLabyrinth(alhSize _size)
{
  size = _size;
  aItem<aCrossroad>* tmpCross;

  crossroads.alRemoveItems();
  srand(time(0));

  for (unsigned short i = 0; i < crsMax[size]; ++i)
  {
    tmpCross = crossroads.alAddItem();
    tmpCross->data.pos.avSet(float(rand()%sizes[size]) - float(sizes[size])/2.0f, 0.0f, float(rand()%sizes[size]) - float(sizes[size])/2.0f);
  }
}

//=============================================================================

void aLabyrinth::alDrawLabyrinth()
{
  glDisable(GL_TEXTURE_2D);
  aItem<aCrossroad>* tmpVector = crossroads.alGetFirstItem();

  while(tmpVector)
  {
    glColor3ub(0, 0, 255);
    glBegin(GL_POINTS);
      glVertex3f(tmpVector->data.pos.x, tmpVector->data.pos.y, tmpVector->data.pos.z);
    glEnd();
    tmpVector = tmpVector->next;
  }

  glEnable(GL_TEXTURE_2D);
}

//=============================================================================

void aLabyrinth::alClearLabyrinth()
{
  crossroads.alRemoveItems();
}

//=============================================================================

aLabyrinth::~aLabyrinth()
{
}

//=============================================================================
